# Contributor: David Huffman <storedbox@outlook.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libdwarf
pkgver=0.9.0
pkgrel=0
pkgdesc="Parsing library for DWARF2 and later debugging file format"
url="https://www.prevanders.net/dwarf.html"
arch="all"
license="LGPL-2.1-only"
makedepends="elfutils-dev meson python3 zlib-dev zstd-dev"
subpackages="liblibdwarfp $pkgname-dev dwarf-tools dwarf-tools-doc"
source="https://www.prevanders.net/libdwarf-$pkgver.tar.xz"

# secfixes:
#   0.6.0-r0:
#     - CVE-2019-14249
#     - CVE-2015-8538

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddwarfgen=true \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

liblibdwarfp() {
	amove usr/lib/libdwarfp.so.*
}

tools() {
	license="GPL-2.0-only AND BSD-3-Clause"
	pkgdesc="Tools for interacting with DWARF2 and later debugging files"

	amove usr/bin usr/share/dwarfdump
}

sha512sums="
282d90dfc9da704eb64a4ba1141f2ae660feeb14bbf1a72377386698e3124928b44a6914d8e88e6141ab08835ce723ad090a853ad57dbcb439dbba57255fb589  libdwarf-0.9.0.tar.xz
"
